package com.offline.module.base.canal;

import com.offline.module.base.entity.GoodsInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import top.javatool.canal.client.annotation.CanalTable;
import top.javatool.canal.client.handler.EntryHandler;

/**
 * @author ZhangHaiWen
 * @title: GoodsInfoHandler
 * @projectName mybatisplustest
 * @description: 监控 goods_info 表发生变化时候
 * https://segmentfault.com/a/1190000022773865
 * @date 2022/3/1412:45
 */
@Slf4j
@Component
@CanalTable(value = "goods_info")
public class GoodsInfoHandler implements EntryHandler<GoodsInfo> {

    /**
     * 插入时
     * @param goodsInfo
     */
    @Override
    public void insert(GoodsInfo goodsInfo) {
        log.info(goodsInfo.toString());
    }

    /**
     * 更新时候
     * @param before 更新前的数据
     * @param after 更新后的数据
     */
    @Override
    public void update(GoodsInfo before, GoodsInfo after) {
        log.info(after.toString());
    }

    /**
     *  删除时的数据
     * @param goodsInfo
     */
    @Override
    public void delete(GoodsInfo goodsInfo) {
        log.info(goodsInfo.toString());
    }
}
